import {
    Entity,
    Column,
    PrimaryGeneratedColumn,
    CreateDateColumn,
    UpdateDateColumn,
  } from 'typeorm';
  
  @Entity('tasks')
  export class Task {
    @PrimaryGeneratedColumn({
      type: 'int',
      comment: '主键id',
    })
    tid: number;
  
    @Column('varchar', {
      nullable: false,
      comment: '任务名字',
    })
    name: string;

    @Column('varchar', {
      nullable: false,
      comment: '任务描述',
    })
    description: string;
  
    @Column( {
      nullable: false,
      comment: '任务创建者',
    })
    uid: number;
  
    @Column({
      nullable: false,
      comment: '任务的模式',
    })
    mid: number;
  
    @CreateDateColumn({
      type: 'timestamp',
      name: 'created_at',
      comment: '任务创建时间',
    })
    createAt: Date;
  
    @CreateDateColumn({
      type: 'timestamp',
      name: 'start_at',
      comment: '任务开始时间',
    })
    startAt: Date;
  
    @UpdateDateColumn({
      type: 'timestamp',
      name: 'updated_at',
      comment: '最后更新时间',
    })
    updatedAt: Date;

    @Column({
        type: 'timestamp',
        name: 'ended_at',
        comment: '任务结束时间',
      })
      endedAt: Date;

  
    @Column('enum', {
      nullable: false,
      default: 0,
      enum: [0, 1, 2],
      comment: '任务状态，0任务未开始，1任务中，2任务结束',
    })
    state: number;
  
    @Column('enum', {
      nullable: false,
      default: 0,
      enum: [0, 1, 2, 3],
      comment: '任务等级，0-3数字越大对应等级越高',
    })
    level: number;
  
    @Column({
      nullable: false,
      comment: '顺序位置',
    })
    index: number;
  }
  